#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+10;
int n,m,sq,nn,a[MAXN],b[MAXN],pos[MAXN],add[MAXN];
void reset(int x)
{
	int l=(x-1)*sq+1,r=min(n,x*sq);
	for(int i=l;i<=r;++i)b[i]=a[i];
	sort(b+l,b+r+1);
	return;
}
int find(int x,int v)
{
	int l=(x-1)*sq+1,r=min(n,x*sq);
	return r-(lower_bound(b+l,b+r+1,v)-b)+1;
}
void update(int x,int y,int v)
{
	if(pos[x]==pos[y])
	{
		for(int i=x;i<=y;++i)a[i]+=v;
		reset(pos[x]);
	}
	else
	{
		int t=min(pos[x]*sq,n);
		for(int i=x;i<=t;++i)a[i]+=v;
		reset(pos[x]);
		t=(pos[y]-1)*sq+1;
		for(int i=t;i<=y;++i)a[i]+=v;
		reset(pos[y]);
	}
	for(int i=pos[x]+1;i<pos[y];++i)
		add[i]+=v;
	return;
}
int query(int x,int y,int v)
{
	int ret=0;
	if(pos[x]==pos[y])
	{
		for(int i=x;i<=y;++i)
			if(a[i]+add[pos[i]]>=v)++ret;
	}
	else
	{
		int t=min(pos[x]*sq,n);
		for(int i=x;i<=t;++i)
			if(a[i]+add[pos[x]]>=v)++ret;
		t=(pos[y]-1)*sq+1;
		for(int i=t;i<=y;++i)
			if(a[i]+add[pos[y]]>=v)++ret;
	}
	for(int i=pos[x]+1;i<pos[y];++i)
		ret+=find(i,v-add[i]);
	return ret;
}
int main()
{
	scanf("%d%d",&n,&m);
	sq=sqrt(n);
	if(!(n%sq))nn=n/sq;
	else nn=n/sq+1;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
		pos[i]=(i-1)/sq+1;
	}
	for(int i=1;i<=nn;++i)reset(i);
	while(m--)
	{
		char t1[3];
		int t2,t3,t4;
		scanf("%s",t1);
		scanf("%d%d%d",&t2,&t3,&t4);
		if(t1[0]=='M')update(t2,t3,t4);
		else printf("%d\n",query(t2,t3,t4));
	}
	return 0;
}
